// utils/directives.js

export const vDebounce = {
  mounted(el, binding) {
    let timer = null;
    el.addEventListener("click", () => {
      if (timer) clearTimeout(timer);
      timer = setTimeout(() => {
        binding.value(); // 执行绑定的函数
        timer = null; // 重置计时器
      }, binding.arg || 300); // 默认 300ms 防抖
    });
  },
  unmounted(el) {
    el.removeEventListener("click", () => {}); // 清除事件监听器
  },
};
